/**
 * Payment 相关逻辑实现类
 * @author WangXinLei
 * @date 2014-11-13
 */
package com.chnbst.bstyun.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.chnbst.bstyun.core.base.BaseService;
import com.chnbst.bstyun.core.common.helper.DaoHelper;
import com.chnbst.bstyun.model.pojo.Payment;
import com.chnbst.bstyun.model.vo.PaymentVo;
import com.chnbst.bstyun.service.PaymentService;

@Transactional
@Service
public class PaymentServiceImpl extends BaseService implements PaymentService {

	private final static String nameSpace = "com.chnbst.bstyun.mapper.PaymentMapper";
	
	@Transactional(propagation=Propagation.REQUIRED,readOnly=false)
	@Override
	public boolean insertPayment(Payment payment) {
		return DaoHelper.insert(nameSpace, "insertPayment", payment);
	}

	@Transactional(propagation=Propagation.REQUIRED,readOnly=false)
	@Override
	public boolean updatePayment(Payment payment) {
		return DaoHelper.update(nameSpace, "updatePayment", payment);
	}
	
	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public Payment selectPaymentByPaymentId(Integer paymentId) {
		return (Payment)DaoHelper.query(nameSpace, "selectPaymentByPaymentId", paymentId);
	}

	@SuppressWarnings("unchecked")
	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public List<PaymentVo> selectPaymentByUserId(Integer userId) {
		return (List<PaymentVo>)DaoHelper.list(nameSpace, "selectPaymentByUserId", userId);
	}

	@Override
	public String selectBigNumByDealType(String dealType) {
		return (String) DaoHelper.query(nameSpace, "selectBigNumByDealType", dealType);
	}

	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public PaymentVo selectPaymentVoByPaymentId(Integer paymentId) {
		return (PaymentVo)DaoHelper.query(nameSpace, "selectPaymentVoByPaymentId", paymentId);
	}

	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public int selectPaymentCount(Map<String, Object> map) {
		return DaoHelper.count(nameSpace, "selectPaymentCount", map);
	}

	@SuppressWarnings("unchecked")
	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public List<Payment> selectAllPayments(Map<String, Object> map) {
		return (List<Payment>) DaoHelper.list(nameSpace, "selectAllPayments", map);
	}

	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public Payment selectPaymentByOrderId(Integer orderId) {
		return (Payment)DaoHelper.query(nameSpace, "selectPaymentByOrderId", orderId);
	}

}
